function showMem() {
  const mem = process.memoryUsage()
  function format(bytes) {
    let target = {}
    for (let key in bytes) {
      target[key] = (bytes[key] / 1024 / 1024).toFixed(2) + 'MB'
    }
    return target
  }
  const formatMemData = format(mem)
  console.log(`Process: heapTotal ${formatMemData.heapTotal} heapUsed ${formatMemData.heapUsed} rss ${formatMemData.rss}`)
}

function useMem() {
  let size = 20 * 1024 * 1024
  let arr = new Array(size)
  for (let i = 0; i < size; i++) {
    arr[i] = 0
  }
  return arr
}

function useMemOfBuffer() {
  let size = 200 * 1024 * 1024
  let buffer = new Buffer(size)
  for (let i = 0; i < size; i++) {
    buffer[i] = 0
  }
  return buffer
}


let total = []

for (let i = 0; i < 15; i++) {
  showMem()
  // total.push(useMem())
  total.push(useMemOfBuffer())
}
showMem()